<?php

namespace common\validate;

class Contract extends BaseValidate
{
    // 验证规则
    protected $rule = [];

    // Fields 验证场景定义
    public function sceneFields()
    {
        return $this;
    }

    // Find 验证场景定义
    public function sceneFind()
    {
        return $this->append('param', 'require')
            ->append('param.filter', 'array');
    }

    // Select 验证场景定义
    public function sceneSelect()
    {
        return $this->append('param', 'require')
            ->append('param.filter', 'array')
            ->append('param.page', 'array');
    }

    public function sceneCreate()
    {
        return $this
            ->append("data.contract_template_id", "integer")
//            ->append("data.from_tenant_id", "require")
//            ->append("data.to_tenant_id", "require")
            ->append("data.type", "require")
            ->append("data.start_time", "date")
            ->append("data.end_time", "date");
//            ->append("data.param.supplier_id", "requireIf:type,contract_type_project|integer");
    }

    // Update 验证场景定义
    public function sceneUpdate()
    {
        return $this->append('data.id', 'require')
            ->append('data.name', 'max:128')
            ->append('data.code', 'max:128');
    }

    // Delete 验证场景定义
    public function sceneDelete()
    {
        return $this->append('param.filter', 'require');
    }

    // GetContractList 验证场景定义
    public function sceneGetContractList()
    {
        return $this
            ->append("param.type", "integer")
            ->append("param.filter", "array")
            ->append("param.page", "array");
    }

    // GetContractDetail 验证场景定义
    public function sceneGetContractDetail()
    {
        return $this->append("param.filter", "require|array");
    }

    // Status 验证场景定义
    public function sceneStatus()
    {
        return $this->append("param.filter", "require|array");
    }
}
